<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>    
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'left.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<!--框架必需start-->
<script type="text/javascript" src="ui/js/jquery.js"></script>
<script type="text/javascript" src="ui/js/framework.js"></script>
<link href="ui/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" id="skin" prePath=""/>
<link rel="stylesheet" type="text/css" id="customSkin"/>
<!--框架必需end-->

<!-- 树start-->
<script type="text/javascript" src="ui/js/tree/ztree/ztree.js"></script>
<link href="ui/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
<link href="ui/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
	var setting = {
		callback: {
			onClick: onClick
		}
	};
	var zNodes =[
		{id:0,name:"系统"},
		{ id:3000, parentId:0, name:"系统配置"},
		{ id:001, parentId:3000, name:"初始派遣配置",version:"trial",url:"<%=path%>/dispatchCfg.action?adminId="+"${sessionScope.userId}", target:"frmright",title:"初始派遣配置"}	,
		{ id:002, parentId:3000, name:"警告配置",version:"trial",url:"<%=path%>/showWaring.action?adminId="+"${sessionScope.userId}", target:"frmright",title:"警告配置"}	
	];
	
	function initComplete(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		//每次刷新时保持上次打开的
		showContent();
	}
	
	function showContent(){
		var treeNodeId=jQuery.jCookie('leftTreeNodeId');
		if(treeNodeId==false||treeNodeId=="false"){}
		else{
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			var node = zTree.getNodeByParam("id", treeNodeId);
			zTree.selectNode(node);
			if(node.url){
				//每次刷新时设置当前位置内容
				if(node.name=="当前位置"){
					top.positionType="normal";
					top.positionContent="当前位置："+node.getParentNode().name+">>"+node.name;
				}
				else{
					top.positionType="none";
				}
				top.frmright.location=node.url;
			}
		}
	}
	
	function onClick(e,treeId, treeNode){
		//单击展开
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.expandNode(treeNode);
		
		//出现进度条
		if(treeNode.url!=null){
			showProgressBar();
		}
		
		//可以设置某些页面出现或者某些页面不出现当前位置组件
		if(treeNode.name=="当前位置"){
			//每次点击时设置当前位置内容
			top.positionContent="当前位置："+treeNode.getParentNode().name+">>"+treeNode.name;
			top.positionType="normal";
		}
		else{
			top.positionType="none";
		}
		
		//存储点击节点id
		jQuery.jCookie('leftTreeNodeId',treeNode.id.toString());
	}

	function  showAll(){
		var treeObj=$.fn.zTree.getZTreeObj("treeDemo");
		treeObj.expandAll(true);
	}
	function  hideAll(){
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		treeObj.expandAll(false);
	}
</script>
<!-- 树end -->
<style>
.ztree *{
	font-family:sans-serif!important;
}
</style>
</head>

<body leftFrame="true" style="background-color:#f1f8ff">
	<div class="padding_top5 ali02">
		<a onclick="showAll()">全部展开</a>&nbsp;&nbsp;<a onclick="hideAll()">全部收缩</a>
		<br>
	</div>
	<div id="scrollContent">
		<div>
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</div>	
  </body>
</html>
